Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script: use "display" instead of "value" in debug output #1568

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

matte-schwartz
Copy link

@matte-schwartz matte-schwartz commented Oct 8, 2024

"value" is not used or defined in either device's lua config for the matches function. Instead, use "display" for the debug output string.

Fixes a coredump when entering gamescope-session on ROG Ally. whoops

"value" is not used or defined in either device's lua config.
Instead, use "display" for the debug output string.

Fixes a coredump when entering gamescope-session on ROG Ally.
@misyltoad
Copy link
Collaborator

Hmmm... probably shouldnt coredump in that state. Maybe something going wrong with the lua error handling?

@misyltoad
Copy link
Collaborator

Will merge, but backtrace would be interesting.

@misyltoad misyltoad merged commit 38e9074 into ValveSoftware:master Oct 8, 2024
1 check passed
@matte-schwartz
Copy link
Author

https://gist.github.com/matte-schwartz/901683a5212757de9b9746db3c35715d journal log leading up to crash + bt

@misyltoad
Copy link
Collaborator

Does the following code fix it?

    std::optional<std::pair<std::string_view, sol::table>> GamescopeScript_t::Config_t::LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel )
    {
        int nMaxPrority = -1;
        std::optional<std::pair<std::string_view, sol::table>> oOutDisplay;

        sol::table tDisplay = script->create_table();
        tDisplay["vendor"] = psvVendor;
        tDisplay["product"] = uProduct;
        tDisplay["model"] = psvModel;

        for ( auto iter : KnownDisplays )
        {
            sol::optional<sol::table> otTable = iter.second.as<sol::optional<sol::table>>();
            if ( !otTable )
                continue;
            sol::table tTable = *otTable;

            sol::optional<sol::function> ofnMatches = tTable["matches"];
            if ( !ofnMatches )
                continue;

            sol::function fnMatches = *ofnMatches;
            if ( !fnMatches )
                continue;

            sol::function_result ret = fnMatches(tDisplay);
            if ( !ret.valid() || !ret.get<sol::optional<int>>() )
                continue;

            int nPriority = ret.get<int>();
            if ( nPriority <= nMaxPrority )
                continue;

            std::string_view psvKey = iter.first.as<std::string_view>();

            nMaxPrority = nPriority;
            oOutDisplay = std::make_pair( psvKey, tTable );
        }

        return oOutDisplay;
    }

does the following code also fix it if so?

    std::optional<std::pair<std::string_view, sol::table>> GamescopeScript_t::Config_t::LookupDisplay( CScriptScopedLock &script, std::string_view psvVendor, uint16_t uProduct, std::string_view psvModel )
    {
        int nMaxPrority = -1;
        std::optional<std::pair<std::string_view, sol::table>> oOutDisplay;

        sol::table tDisplay = script->create_table();
        tDisplay["vendor"] = psvVendor;
        tDisplay["product"] = uProduct;
        tDisplay["model"] = psvModel;

        for ( auto iter : KnownDisplays )
        {
            sol::optional<sol::table> otTable = iter.second.as<sol::optional<sol::table>>();
            if ( !otTable )
                continue;
            sol::table tTable = *otTable;

            sol::optional<sol::function> ofnMatches = tTable["matches"];
            if ( !ofnMatches )
                continue;

            sol::function fnMatches = *ofnMatches;
            if ( !fnMatches )
                continue;

            sol::optional<int> onPriority = fnMatches(tDisplay);
            if ( !onPriority )
                continue;

            int nPriority = *onPriority;
            if ( nPriority <= nMaxPrority )
                continue;

            std::string_view psvKey = iter.first.as<std::string_view>();

            nMaxPrority = nPriority;
            oOutDisplay = std::make_pair( psvKey, tTable );
        }

        return oOutDisplay;
    }

@matte-schwartz
Copy link
Author

I think I answered this but ftr yes, both do work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants